home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / winlib.lzh / WINLIB / OBJECTS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-09  |  8.1 KB  |  294 lines

  1. /********************************************************************
  2.  *                                                                    *
  3.  *    WinLIB PRO Revision II: Object manipulation module                *
  4.  *                                                                    *
  5.  *    Copyright (c) 1994, Bitgate Software                            *
  6.  *                                                                    *
  7.  ********************************************************************/
  8.  
  9. #include <aes.h>
  10. #include <stdio.h>
  11.  
  12. #include "winlib.h"
  13.  
  14. #ifdef __TURBOC__
  15. #pragma warn -pia
  16. #endif
  17.  
  18. #ifndef __OBJECTS__
  19. #define __OBJECTS__
  20. #endif
  21.  
  22. /*
  23.  *    Change resource object state
  24.  *
  25.  *    This function *should* be used to change and update objects in windows.
  26.  *    It is an interception of objc_change and changes objects in
  27.  *    the same fashion, but updates objects correctly in windows.
  28.  *
  29.  *    This procedure has the same parameters as objc_change except
  30.  *    for that clipping coordinates are not required.
  31.  */
  32. GLOBAL void Objc_Change(OBJECT *tree, int ob_cobject, int ob_crecvd, int ob_cnewstate, int ob_credraw)
  33. {
  34.     objc_change(tree, ob_cobject, ob_crecvd, 0, 0, 0, 0, ob_cnewstate, 0);
  35.     if (ob_credraw) {
  36.         WINDOW *win = WindowChain;
  37.  
  38.         if (!(win->style & S_MULTICOPYABLE))
  39.             win = (WINDOW *) WLocateWindow('TREE', tree);
  40.  
  41.         if (win->style & S_MULTICOPYABLE) {
  42.             while (win->next) {
  43.                 if (win->tree == tree) {
  44.                     GRECT own, temp;
  45.                     int x, y;
  46.  
  47.                     WMoveWindow(win, -1, -1, -1, -1);
  48.                     objc_offset(win->tree, ob_cobject, &x, &y);
  49.  
  50.                     own.g_x = x;
  51.                     own.g_y = y;
  52.                     own.g_w = win->tree[ob_cobject].ob_width;
  53.                     own.g_h = win->tree[ob_cobject].ob_height;
  54.  
  55.                     wind_update(BEG_UPDATE);
  56.  
  57.                     WWindGet(win, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  58.                     while (temp.g_w && temp.g_h) {
  59.                         if (rc_intersect(&temp, &own)) {
  60.                             switch (win->tree[ob_cobject].ob_type & 0xff) {
  61.                                 case G_BUTTON:
  62.                                 case G_USERDEF:
  63.                                 case G_BOXCHAR:
  64.                                 case G_BOX:
  65.                                 case G_STRING:
  66.                                 case G_IMAGE:
  67.                                     if (ob_cobject == 0)
  68.                                         objc_draw(win->tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  69.                                     else
  70.                                         objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  71.  
  72.                                     break;
  73.  
  74.                                 default:
  75.                                     if ((ob_cobject == 0) || ((win->tree[ob_cobject].ob_type & 0x0F) == G_IMAGE))
  76.                                         objc_draw(win->tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  77.                                     else
  78.                                         objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  79.  
  80.                                     break;
  81.                             }
  82.                         }
  83.  
  84.                         WWindGet(win, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  85.                     }
  86.  
  87.                     wind_update(END_UPDATE);
  88.                 }
  89.                 win = win->next;            
  90.             }
  91.         } else {
  92.             GRECT own, temp;
  93.             int x, y;
  94.  
  95.             WMoveWindow(win, -1, -1, -1, -1);
  96.             objc_offset(win->tree, ob_cobject, &x, &y);
  97.  
  98.             own.g_x = x;
  99.             own.g_y = y;
  100.             own.g_w = win->tree[ob_cobject].ob_width;
  101.             own.g_h = win->tree[ob_cobject].ob_height;
  102.  
  103.             wind_update(BEG_UPDATE);
  104.  
  105.             WWindGet(win, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  106.             while (temp.g_w && temp.g_h) {
  107.                 if (rc_intersect(&temp, &own)) {
  108.                     switch (win->tree[ob_cobject].ob_type & 0xff) {
  109.                         case G_BUTTON:
  110.                         case G_USERDEF:
  111.                         case G_BOXCHAR:
  112.                         case G_BOX:
  113.                         case G_STRING:
  114.                         case G_IMAGE:
  115.                             if (ob_cobject == 0)
  116.                                 objc_draw(win->tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  117.                             else
  118.                                 objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  119.  
  120.                             break;
  121.  
  122.                         default:
  123.                             if ((ob_cobject == 0) || ((win->tree[ob_cobject].ob_type & 0x0F) == G_IMAGE))
  124.                                 objc_draw(win->tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  125.                             else
  126.                                 objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  127.  
  128.                             break;
  129.                     }
  130.                 }
  131.  
  132.                 WWindGet(win, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  133.             }
  134.  
  135.             wind_update(END_UPDATE);
  136.         }
  137.     }
  138. }
  139.  
  140. GLOBAL void WObjc_Change(OBJECT *tree, int ob_cobject, int ob_crecvd, int ob_cnewstate, int ob_credraw)
  141. {
  142.     objc_change(tree, ob_cobject, ob_crecvd, 0, 0, 0, 0, ob_cnewstate, 0);
  143.     if (ob_credraw) {
  144.         GRECT own, temp;
  145.         int x, y;
  146.  
  147.         objc_offset(tree, ob_cobject, &x, &y);
  148.  
  149.         own.g_x = x;
  150.         own.g_y = y;
  151.         own.g_w = tree[ob_cobject].ob_width;
  152.         own.g_h = tree[ob_cobject].ob_height;
  153.  
  154.         wind_update(BEG_UPDATE);
  155.  
  156.         wind_get(0, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  157.         while (temp.g_w && temp.g_h) {
  158.             if (rc_intersect(&temp, &own)) {
  159.                 switch (tree[ob_cobject].ob_type & 0xff) {
  160.                     case G_BUTTON:
  161.                     case G_USERDEF:
  162.                     case G_BOXCHAR:
  163.                     case G_BOX:
  164.                     case G_STRING:
  165.                     case G_IMAGE:
  166.                         if (ob_cobject == 0)
  167.                             objc_draw(tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  168.                         else
  169.                             objc_draw(tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  170.  
  171.                         break;
  172.  
  173.                     default:
  174.                         if ((ob_cobject == 0) || ((tree[ob_cobject].ob_type & 0x0F) == G_IMAGE))
  175.                             objc_draw(tree, 0, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  176.                         else
  177.                             objc_draw(tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  178.  
  179.                         break;
  180.                 }
  181.             }
  182.  
  183.             wind_get(0, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  184.         }
  185.  
  186.         wind_update(END_UPDATE);
  187.     }
  188. }
  189.  
  190. GLOBAL void WObjc_Draw(OBJECT *tree, int ob_cobject, int ob_cdepth, int clipx, int clipy, int clipw, int cliph)
  191. {
  192.     WINDOW *win = WindowChain;
  193.  
  194.     if (!(win->style & S_MULTICOPYABLE))
  195.         win = (WINDOW *) WLocateWindow('TREE', tree);
  196.  
  197.     if (win->style & S_MULTICOPYABLE) {
  198.         while (win->next) {
  199.             if (win->tree == tree) {
  200.                 GRECT own, temp;
  201.                 int x, y;
  202.  
  203.                 WMoveWindow(win, -1, -1, -1, -1);
  204.                 objc_offset(win->tree, ob_cobject, &x, &y);
  205.  
  206.                 own.g_x = x;
  207.                 own.g_y = y;
  208.                 own.g_w = win->tree[ob_cobject].ob_width;
  209.                 own.g_h = win->tree[ob_cobject].ob_height;
  210.  
  211.                 wind_update(BEG_UPDATE);
  212.  
  213.                 WWindGet(win, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  214.                 while (temp.g_w && temp.g_h) {
  215.                     if (rc_intersect(&temp, &own)) {
  216.                         switch (win->tree[ob_cobject].ob_type & 0xff) {
  217.                             case G_BUTTON:
  218.                             case G_USERDEF:
  219.                             case G_BOXCHAR:
  220.                             case G_BOX:
  221.                             case G_STRING:
  222.                             case G_IMAGE:
  223.                                 if (ob_cobject == 0)
  224.                                     objc_draw(win->tree, ob_cobject, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  225.                                 else
  226.                                     objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  227.  
  228.                                 break;
  229.  
  230.                             default:
  231.                                 if ((ob_cobject == 0) || ((win->tree[ob_cobject].ob_type & 0x0F) == G_IMAGE))
  232.                                     objc_draw(win->tree, ob_cobject, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  233.                                 else
  234.                                     objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  235.  
  236.                                 break;
  237.                         }
  238.                     }
  239.  
  240.                     WWindGet(win, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  241.                 }
  242.  
  243.                 wind_update(END_UPDATE);
  244.             }
  245.             win = win->next;
  246.         }
  247.     } else {
  248.         GRECT own, temp;
  249.         int x, y;
  250.  
  251.         WMoveWindow(win, -1, -1, -1, -1);
  252.         objc_offset(win->tree, ob_cobject, &x, &y);
  253.  
  254.         own.g_x = x;
  255.         own.g_y = y;
  256.         own.g_w = win->tree[ob_cobject].ob_width;
  257.         own.g_h = win->tree[ob_cobject].ob_height;
  258.  
  259.         wind_update(BEG_UPDATE);
  260.  
  261.         WWindGet(win, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  262.         while (temp.g_w && temp.g_h) {
  263.             if (rc_intersect(&temp, &own)) {
  264.                 switch (win->tree[ob_cobject].ob_type & 0xff) {
  265.                     case G_BUTTON:
  266.                     case G_USERDEF:
  267.                     case G_BOXCHAR:
  268.                     case G_BOX:
  269.                     case G_STRING:
  270.                     case G_IMAGE:
  271.                         if (ob_cobject == 0)
  272.                             objc_draw(win->tree, ob_cobject, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  273.                         else
  274.                             objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  275.  
  276.                         break;
  277.  
  278.                     default:
  279.                         if ((ob_cobject == 0) || ((win->tree[ob_cobject].ob_type & 0x0F) == G_IMAGE))
  280.                             objc_draw(win->tree, ob_cobject, 99, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  281.                         else
  282.                             objc_draw(win->tree, ob_cobject, 2, temp.g_x, temp.g_y, temp.g_w, temp.g_h);
  283.  
  284.                         break;
  285.                 }
  286.             }
  287.  
  288.             WWindGet(win, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  289.         }
  290.  
  291.         wind_update(END_UPDATE);
  292.     }
  293. }
  294.